@extends('adminlte::page')

@section('title', 'Dashboard')

@section('content_header')
    <h1>Dashboard</h1>
@stop

<!-- -->

@section('js')
    <script> console.log('Hi!'); </script>
    <script>
    	$(function(){

    		$.ajaxSetup({
			    headers: {
			        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
			    }
			});

    		$(".fa-trash-alt").on('click', function() {
    			//Swal.fire('Any fool can use a computer')
    			let msg = $(this).data('msa');
    			msg = msg? msg : "are you sure to delete";
    			const url = $(this).data('url');
    			Swal.fire({
    				title:msg,
    				showDenyButton: true,
					showCancelButton: true,
					confirmButtonText: `delete`,
					denyButtonText: `cancel`,
    			}).then(res => {
    				console.log(res)
    				if(res.value) {
    					$.ajax({
    						url:url,
    						type:"delete",
    						success: res => {
    							console.log(res)
    							location.reload();
    						},
    						error: res=> {
    							//console.log(res)
    							//alert(res.responseJSON.msg);
    							Swal.fire(res.responseJSON.msg)
    						}
    					})
    				}
    			})
    		})
    	})
    </script>
@stop
